package com.leisurexi.ioc.common.annotation;

import com.leisurexi.ioc.domain.User;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;

import javax.annotation.Resource;

/**
 * @author: leisurexi
 * @date: 2020-07-07 23:11
 * @since JDK 1.8
 */
public class CommonAnnotationDemo {

	@Resource
	private User user;

	public static void main(String[] args) {
		AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext();
		applicationContext.register(CommonAnnotationDemo.class);
		applicationContext.refresh();
		User user = applicationContext.getBean("user", User.class);
		System.err.println(user);
		applicationContext.close();
	}

	@Bean
	public User user() {
		User user = new User();
		user.setId(1L);
		user.setName("dasd");
		return user;
	}

}
